require("core.util")
local sounds = require("prototypes.entity.sounds")

data:extend(
    {
        {
            type = "projectile",
            name = "atomic-rocket",
            flags = {"not-on-map"},
            acceleration = 0.05,
            turn_speed = 0.03,
            turning_speed_increases_exponentially_with_projectile_speed = true,
            action = {
                type = "direct",
                action_delivery = {
                    type = "instant",
                    target_effects = {
                        {
                            type = "set-tile",
                            tile_name = "nuclear-ground",
                            radius = 12,
                            apply_projection = true,
                            tile_collision_mask = {"water-tile"}
                        },
                        {
                            type = "destroy-cliffs",
                            radius = 100,
                            explosion = "explosion"
                        },
                        {
                            type = "create-entity",
                            entity_name = "nuke-explosion"
                        },
                        {
                            type = "camera-effect",
                            effect = "screen-burn",
                            duration = 10,
                            ease_in_duration = 5,
                            ease_out_duration = 10,
                            delay = 0,
                            strength = 500,
                            full_strength_max_distance = 9000,
                            max_distance = 1000
                        },
                        {
                            type = "play-sound",
                            sound = sounds.nuclear_explosion(0.9),
                            play_on_target_position = false,
                            -- min_distance = 200,
                            max_distance = 1000,
                            -- volume_modifier = 1,
                            audible_distance_modifier = 3
                        },
                        {
                            type = "play-sound",
                            sound = sounds.nuclear_explosion_aftershock(0.4),
                            play_on_target_position = false,
                            -- min_distance = 200,
                            max_distance = 1000,
                            -- volume_modifier = 1,
                            audible_distance_modifier = 3
                        },
                        {
                            type = "damage",
                            damage = {amount = 6000000000, type = "explosion"}
                        },
                        {
                            type = "create-entity",
                            entity_name = "huge-scorchmark",
                            offsets = {{0, -0.5}},
                            check_buildability = true
                        },
                        {
                            type = "invoke-tile-trigger",
                            repeat_count = 1000
                        },
                        {
                            type = "destroy-decoratives",
                            include_soft_decoratives = true, -- soft decoratives are decoratives with grows_through_rail_path = true
                            include_decals = true,
                            invoke_decorative_trigger = true,
                            decoratives_with_trigger_only = false, -- if true, destroys only decoratives that have trigger_effect set
                            radius = 14 -- large radius for demostrative purposes
                        },
                        {
                            type = "create-decorative",
                            decorative = "nuclear-ground-patch",
                            spawn_min_radius = 11.5,
                            spawn_max_radius = 12.5,
                            spawn_min = 30,
                            spawn_max = 40,
                            apply_projection = true,
                            spread_evenly = true
                        },
                        {
                            type = "nested-result",
                            action = {
                                type = "area",
                                target_entities = false,
                                trigger_from_target = true,
                                repeat_count = 1000,
                                radius = 50,
                                action_delivery = {
                                    type = "projectile",
                                    projectile = "atomic-bomb-ground-zero-projectile",
                                    starting_speed = 0.6 * 0.8,
                                    starting_speed_deviation = nuke_shockwave_starting_speed_deviation
                                }
                            }
                        },
                        {
                            type = "nested-result",
                            action = {
                                type = "area",
                                target_entities = false,
                                trigger_from_target = true,
                                repeat_count = 1000,
                                radius = 50,
                                action_delivery = {
                                    type = "projectile",
                                    projectile = "atomic-bomb-wave",
                                    starting_speed = 0.5 * 0.7,
                                    starting_speed_deviation = nuke_shockwave_starting_speed_deviation
                                }
                            }
                        },
                        {
                            type = "nested-result",
                            action = {
                                type = "area",
                                show_in_tooltip = false,
                                target_entities = false,
                                trigger_from_target = true,
                                repeat_count = 1000,
                                radius = 50,
                                action_delivery = {
                                    type = "projectile",
                                    projectile = "atomic-bomb-wave-spawns-cluster-nuke-explosion",
                                    starting_speed = 0.5 * 0.7,
                                    starting_speed_deviation = nuke_shockwave_starting_speed_deviation
                                }
                            }
                        },
                        {
                            type = "nested-result",
                            action = {
                                type = "area",
                                show_in_tooltip = false,
                                target_entities = false,
                                trigger_from_target = true,
                                repeat_count = 1000,
                                radius = 50,
                                action_delivery = {
                                    type = "projectile",
                                    projectile = "atomic-bomb-wave-spawns-fire-smoke-explosion",
                                    starting_speed = 0.5 * 0.65,
                                    starting_speed_deviation = nuke_shockwave_starting_speed_deviation
                                }
                            }
                        },
                        {
                            type = "nested-result",
                            action = {
                                type = "area",
                                show_in_tooltip = false,
                                target_entities = false,
                                trigger_from_target = true,
                                repeat_count = 1000,
                                radius = 50,
                                action_delivery = {
                                    type = "projectile",
                                    projectile = "atomic-bomb-wave-spawns-nuke-shockwave-explosion",
                                    starting_speed = 0.5 * 0.65,
                                    starting_speed_deviation = nuke_shockwave_starting_speed_deviation
                                }
                            }
                        },
                        {
                            type = "nested-result",
                            action = {
                                type = "area",
                                show_in_tooltip = false,
                                target_entities = false,
                                trigger_from_target = true,
                                repeat_count = 1000,
                                radius = 50,
                                action_delivery = {
                                    type = "projectile",
                                    projectile = "atomic-bomb-wave-spawns-nuclear-smoke",
                                    starting_speed = 0.5 * 0.65,
                                    starting_speed_deviation = nuke_shockwave_starting_speed_deviation
                                }
                            }
                        },
                        {
                            type = "nested-result",
                            action = {
                                type = "area",
                                show_in_tooltip = false,
                                target_entities = false,
                                trigger_from_target = true,
                                repeat_count = 1000,
                                radius = 50,
                                action_delivery = {
                                    type = "instant",
                                    target_effects = {
                                        {
                                            type = "create-entity",
                                            entity_name = "nuclear-smouldering-smoke-source",
                                            tile_collision_mask = {"water-tile"}
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            },
            --light = {intensity = 0.8, size = 15},
            animation = {
                filename = "__base__/graphics/entity/rocket/rocket.png",
                draw_as_glow = true,
                frame_count = 8,
                line_length = 8,
                width = 9,
                height = 35,
                shift = {0, 0},
                priority = "high"
            },
            shadow = {
                filename = "__base__/graphics/entity/rocket/rocket-shadow.png",
                frame_count = 1,
                width = 7,
                height = 24,
                priority = "high",
                shift = {0, 0}
            },
            smoke = {
                {
                    name = "smoke-fast",
                    deviation = {0.15, 0.15},
                    frequency = 1,
                    position = {0, 1},
                    slow_down_factor = 1,
                    starting_frame = 3,
                    starting_frame_deviation = 5,
                    starting_frame_speed = 0,
                    starting_frame_speed_deviation = 5
                }
            }
        }
    }
)
